package com.lc.admin.web;

import com.lc.admin.base.PageResponse;
import com.lc.admin.base.ResponseResult;
import com.lc.admin.bean.NursingPlan;
import com.lc.admin.constants.PagerConstants;
import com.lc.admin.service.NursingPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/nursing_plan")
//@Api(tags="护理计划接口")
public class NursingPlanWeb {

    @Autowired
    NursingPlanService nursingPlanService;

    /**
     * 分页条件查询接口
     * @return
     */
    @GetMapping("/list")
//    @ApiOperation("护理计划分页条件查询")
    public ResponseResult<PageResponse<NursingPlan>> list(
            @RequestParam(defaultValue = PagerConstants.PAGE_STR) Integer page,
            @RequestParam(defaultValue = "100") Integer pageSize,
            String name,
            Integer status
    ){
        PageResponse<NursingPlan> pageResponse = nursingPlanService.list(page,pageSize,name,status);
        return ResponseResult.success(pageResponse);
    }

    // 需要一个文件上传接口，传到阿里云服务器oss   会返回一个图片在阿里云的存储地址

    @PostMapping("/save")
//    @ApiOperation("新增护理计划")
    public ResponseResult save(@RequestBody NursingPlan NursingPlan) {
        nursingPlanService.save(NursingPlan);

        return ResponseResult.success();
    }

    @GetMapping("/findById/{id}")
//    @ApiOperation("根据id查询护理计划")
    public ResponseResult<NursingPlan> findById( @PathVariable("id") Long id) {
        NursingPlan NursingPlan = nursingPlanService.findById(id);
        return ResponseResult.success(NursingPlan);
    }

    @PutMapping("/edit")
//    @ApiOperation("编辑护理计划")
    public ResponseResult edit(@RequestBody NursingPlan NursingPlan) {
        nursingPlanService.edit(NursingPlan);
        return ResponseResult.success();
    }

    @GetMapping("/enable/{id}/{status}")
//    @ApiOperation("启用或禁用护理计划")
    public ResponseResult enable(
            @PathVariable("id") Long id,
             @PathVariable("status") Integer status) {
        nursingPlanService.enable(id,status);
        return ResponseResult.success();
    }

    @DeleteMapping("/enable/{id}")
//    @ApiOperation("删除护理计划")
    public ResponseResult del(@PathVariable("id") Integer id) {
        nursingPlanService.del(id);
        return ResponseResult.success();
    }


}
